import {
  IsEmpty,
  IsInt,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
  Matches,
} from 'class-validator';

export class CreateUserDto {
  @IsNotEmpty()
  account: string;
  @IsNotEmpty()
  password: string;
  @IsNotEmpty()
  userName: string;
  @Matches(/^(\+?\d{1,4}[-.\s]?|)?\d{10}$/, {
    message: 'Phone number must be a valid format',
  })
  phoneNum: string;
  @IsOptional()
  desc: string;
  @IsOptional()
  avatar: string;
}

export class UpdateUserDto {
  @IsNotEmpty()
  userName: string;
  @Matches(/^(\+?\d{1,4}[-.\s]?|)?\d{10}$/, {
    message: 'Phone number must be a valid format',
  })
  phoneNum: string;
  @IsOptional()
  desc: string;
  @IsOptional()
  avatar: string;
}

export class LoginUserDto {
  @IsString()
  account: string;
  @IsString()
  password: string;
  @IsString()
  code: string;
}

export class GetUserDto {
  @IsNotEmpty()
  @IsInt()
  pageSize: number;
  @IsNotEmpty()
  @IsInt()
  page: number;
  @IsString()
  userName: string;
}

export class UpdatePasswordDto {
  @IsNumber()
  id: number;
  @IsNotEmpty()
  oldPassword: string;
  @IsNotEmpty()
  newPassword: string;
}

export class UpdateMyPasswordDto {
  @IsNotEmpty()
  oldPassword: string;
  @IsNotEmpty()
  newPassword: string;
}
